package com.myupload.demo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {
   /*
   staticPatternPath
    */
    @Value("${file.staticPatternPath}")
    private String staticPatternPath;
    //资源映射路径
    @Value("${file.uploadFolder}")
    private String uploadFolder;


    //springboot 添加额外的映射资源
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(staticPatternPath).addResourceLocations("file:"+uploadFolder);

        //第一个参数访问的路径，第二个参数 资源的映射路径，这个就可以访问了
    }
}
